<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>记账簿</title>
  <!--[if lt IE 9]>
  <script src="libs/html5shiv.min.js"></script>
  <script src="libs/respond.min.js"></script>
  <![endif]-->
  <script src="libs/jquery-1.12.1.min.js"></script>
  <link href="libs/bootstrap-3.3.6/css/bootstrap.min.css" rel="stylesheet">
  <script src="libs/bootstrap-3.3.6/js/bootstrap.min.js"></script>
  <script src="libs/handlebars.min.js" type="text/javascript"></script>
</head>
<body>
<div class="container">
    <div class="row">
      <div class="page-header">
      <h1 align="center"><strong>XXX记账</strong></h2>
      </div>
    </div>
  </div>
<div class="container">
  <div class="row">
    <div class="col-md-8">
      <ul class="nav nav-pills">
        <li class="active">
        <a href="#">首页</a>
        </li>
        <li>
        <a href="moneyOut.html"><strong>新加支出</strong></a>
        </li>
         <li>
        <a href="moneyIn.html"><strong>新加收入</strong></a>
        </li>
        <li>
        <a href="statis.html"><strong>统计</strong></a>
        </li>
         <li>
        <a href="query.html"><strong>查询</strong></a>
        </li>
         </li>
         <li>
      <a href="login.html"><strong>(切换)用户：</strong><span id="text3"></span></a>
        </li>
      </ul>
    </div>
     <div class="col-md-offset-11">
     <ul class="nav nav-pills">
     <li>
      <button id="cleanCookie" class="btn btn-primary btn-block"><strong>退出</strong></button>
     </li>
     </ul>
     </div>
  </div>
</div>
<div class="container">
  <div class="row">
    <div class="col-md-12">
      <hr/>
    </div>
  </div>
</div>
<div class="container">
<h1>
    <div class="row">
      <div class="col-md-6">
        <div class="panel panel-primary">
          <div class="panel-heading"><strong>一周内的收入</strong></div>
          <div class="panel-body" id="text1"></div>
        </div>
      </div>
         <div class="col-md-6">
        <div class="panel panel-primary">
          <div class="panel-heading"><strong>一周内的支出</strong></div>
          <div class="panel-body" id="text2"></div>
        </div>
      </div>
    </div>
</h1>
     <div class="row">
      <div class="col-md-12">
        <div class="panel panel-success">
          <div class="panel-heading"><h4><strong>最近的四笔收入</strong></h4></div>
          <div class="panel-body" id="list1"></div>
        </div>
      </div>
    </div>
     <div class="row">
      <div class="col-md-12">
        <div class="panel panel-success">
          <div class="panel-heading"><h4><strong>最近的四笔支出</strong></h4></div>
          <div class="panel-body" id="list2"></div>
        </div>
      </div>
    </div>
  </div>
<script type="text/x-handlebars-template" id="template">
{{#each item}}
<div class="panel panel-default col-md-3">
  <div class="panel-body">
  <dl>
  <dt>时间</dt><dd>{{date_time}}</dd>
  <dt>地点</dt><dd>{{place}}</dd>
  <dt>金额</dt><dd>{{money_in}}</dd>
  <dt>类别</dt><dd>{{kind}}</dd>
  </dl>
  </div>
</div>
{{/each}}
</script>
<script type="text/x-handlebars-template" id="template1">
{{#each item}}
<div class="panel panel-default col-md-3">
  <div class="panel-body">
  <dl>
  <dt>时间</dt><dd>{{date_time}}</dd>
  <dt>地点</dt><dd>{{place}}</dd>
  <dt>金额</dt><dd>{{money_out}}</dd>
  <dt>类别</dt><dd>{{kind}}</dd>
  </dl>
  </div>
</div>
{{/each}}
</script>
<script type="text/javascript">
	
  $(function (){ 
	        $.getJSON('query_money.action', function(res){
	       $('#text1').text(res.si); 
	       $('#text2').text(res.so);
	  });
	        
	        $.getJSON('queryuser.action', function(res){
		 	       
		 	       $('#text3').text(res.nickname);   
		  });
	        $.getJSON('queryJQI.action', function(res){
		 	       var data ={'item':res};
		 	       var t=Handlebars.compile($('#template').html());
		 	       $('#list1').html(t(data));
		 	     
		 	          
		  });
	        $.getJSON('queryJQO.action', function(res){
		 	       var data ={'item':res};
		 	       var t=Handlebars.compile($('#template1').html());
		 	       $('#list2').html(t(data));
		 	     
		 	          
		  });
	       
	        
  })

  </script>
  <script type="text/javascript">
  $(function () {
	    $('#cleanCookie').click(function () {
	        $.post('cleanCookie.action', {
	       
	       
	      }, function (res, status) {
	        if ('OK' == res) {
	         window.location.href='login.html';
	        } 
	      });
	    });
	  });

  </script>
</body>
</html>